USE [darskade_express]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_privileges_in_role_privilege]') AND parent_object_id = OBJECT_ID(N'[dbo].[privileges_in_role]'))
ALTER TABLE [dbo].[privileges_in_role] DROP CONSTRAINT [FK_privileges_in_role_privilege]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_privileges_in_role_role]') AND parent_object_id = OBJECT_ID(N'[dbo].[privileges_in_role]'))
ALTER TABLE [dbo].[privileges_in_role] DROP CONSTRAINT [FK_privileges_in_role_role]
GO

USE [darskade_express]
GO

/****** Object:  Table [dbo].[privileges_in_role]    Script Date: 12/29/2010 11:04:58 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[privileges_in_role]') AND type in (N'U'))
DROP TABLE [dbo].[privileges_in_role]
GO

USE [darskade_express]
GO

/****** Object:  Table [dbo].[privileges_in_role]    Script Date: 12/29/2010 11:04:58 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[privileges_in_role](
	[role_id] [int] NOT NULL,
	[privilege_id] [int] NOT NULL,
	[id] [int] NOT NULL,
 CONSTRAINT [PK_privileges_in_role] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[privileges_in_role]  WITH CHECK ADD  CONSTRAINT [FK_privileges_in_role_privilege] FOREIGN KEY([privilege_id])
REFERENCES [dbo].[privilege] ([privilege_id])
GO

ALTER TABLE [dbo].[privileges_in_role] CHECK CONSTRAINT [FK_privileges_in_role_privilege]
GO

ALTER TABLE [dbo].[privileges_in_role]  WITH CHECK ADD  CONSTRAINT [FK_privileges_in_role_role] FOREIGN KEY([role_id])
REFERENCES [dbo].[role] ([role_id])
GO

ALTER TABLE [dbo].[privileges_in_role] CHECK CONSTRAINT [FK_privileges_in_role_role]
GO


